<template>
  <div class="login">
    <div class="login-center">
      <ul class="logo">
        <li><span>雪月</span></li>
        <li>
            <div>后台管理系统</div>
            <div>BACKROUND MANACEMENT CENTER</div>
        </li>
      </ul>
      <ul class="login-right">
        <li class="login-li1">
          <div href="javascript:;">
              <em></em>
              <i>SIGN IN</i>
          </div>
          <div href="javascript:;">
              <a href="javascript:;" :plain="true" @click="login">登录</a>
              <em></em>
          </div>
        </li>
        <li class="login-user">
          <span>
              <em></em>
          </span>
          <input type="text" v-model="user.username" placeholder="请输入用户名">
        </li>
        <li class="login-pass">
          <span>
              <em></em>
          </span>
          <input type="password" v-model="user.password" placeholder="请输入密码">
        </li>
        <li class="login-login">
          <el-button type="primary" round class="btn" @click="login">登 录</el-button>
        </li>
        <li class="login-state">
          <input type="checkbox" class="checkbox">
          <em>保持登录状态</em>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import "../assets/css/login.css"
export default {
    name:"login",
    data(){
        return{
            user:{
                username:"admin",
                password:"123456"
            }
        }
    },
    methods:{
        async login(){
            const rst=await this.$http.post("login",this.user);
            if(rst.meta.status!=200){
                this.$message({
                    type:"info",
                    message:rst.meta.msg
                })
            }
            else{
                window.sessionStorage.setItem("token",rst.data.token);
                this.$router.replace("/home");
            }
        }
    }
}
</script>

<style scoped>

</style>